package kaizone.haining.chaobohui.json;

import java.util.ArrayList;
import java.util.List;

import kaizone.haining.chaobohui.json.Item.PicModel;

import org.json.JSONArray;
import org.json.JSONObject;

public class Intro {
    
    public static final String INTRO = "intro";
    public static final String CHAOEXPOINTRO = "chaoExpoIntro";
    public static final String GMTCREATE = "gmtCreate";
    public static final String GMTMODIFIED = "gmtModified";
    public static final String HNINTRO = "hnIntro";
    public static final String HNMAPPICMODELLIST = "hnMapPicModelList";
    public static final String HNMAPPICURLS = "hnMapPicUrls";
    
    private String chaoExpoIntro;
    private String gmtCreate;
    private String gmtModified;
    private String hnIntro;
    private List<Item.PicModel> hnMapPicModelList;
    private String hnMapPicUrls;
    
    public String getChaoExpoIntro() {
        return chaoExpoIntro;
    }
    public void setChaoExpoIntro(String chaoExpoIntro) {
        this.chaoExpoIntro = chaoExpoIntro;
    }
    public String getGmtCreate() {
        return gmtCreate;
    }
    public void setGmtCreate(String gmtCreate) {
        this.gmtCreate = gmtCreate;
    }
    public String getGmtModified() {
        return gmtModified;
    }
    public void setGmtModified(String gmtModified) {
        this.gmtModified = gmtModified;
    }
    public String getHnIntro() {
        return hnIntro;
    }
    public void setHnIntro(String hnIntro) {
        this.hnIntro = hnIntro;
    }
    public List<Item.PicModel> getHnMapPicModelList() {
        return hnMapPicModelList;
    }
    public void setHnMapPicModelList(List<Item.PicModel> hnMapPicModelList) {
        this.hnMapPicModelList = hnMapPicModelList;
    }
    public String getHnMapPicUrls() {
        return hnMapPicUrls;
    }
    public void setHnMapPicUrls(String hnMapPicUrls) {
        this.hnMapPicUrls = hnMapPicUrls;
    }
    
    public static Intro parse(JSONObject jsonObject){
        Intro intro = new Intro();
        
        intro.setChaoExpoIntro(jsonObject.optString(CHAOEXPOINTRO));
        intro.setGmtCreate(jsonObject.optString(GMTCREATE));
        intro.setGmtModified(jsonObject.optString(GMTMODIFIED));
        intro.setHnIntro(jsonObject.optString(HNINTRO));
        intro.setHnMapPicUrls(jsonObject.optString(HNMAPPICURLS));
        
        JSONArray jsonPicModes = jsonObject.optJSONArray(HNMAPPICMODELLIST);
        if (jsonPicModes != null) {
            ArrayList<PicModel> picmodels = new ArrayList<Item.PicModel>();
            int picmodesLen = jsonPicModes.length();
            for (int j = 0; j < picmodesLen; j++) {
                JSONObject jsonPicmodeObj = jsonPicModes.optJSONObject(j);
                PicModel picModel = new PicModel();
                picModel.path = jsonPicmodeObj.optString(PicModel.PATH);
                picModel.sum100x000 = jsonPicmodeObj.optString(PicModel.SUM100X000);
                picModel.url = jsonPicmodeObj.optString(PicModel.URL);
                picmodels.add(picModel);
            }
            intro.setHnMapPicModelList(picmodels);
        }
        return intro;
    }

}
